package com.gravata.enigma.model;

import java.io.Serializable;

import com.j256.ormlite.dao.ForeignCollection;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.field.ForeignCollectionField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable(tableName="service")
public class Service extends EntidadeAbstrata implements Comparable<Service> {

	private static final long serialVersionUID = -1241593666655585194L;

	@DatabaseField(generatedId=true)
	private int id;

	@DatabaseField(canBeNull=false,columnName="sid")
	private String sid;

	@DatabaseField(canBeNull=false,columnName="reference")
	private String reference;

	@DatabaseField(canBeNull=false,columnName="name")
	private String name;

	@DatabaseField(canBeNull=false,columnName="type")
	private int type;

	@DatabaseField(canBeNull=false,foreign=true,foreignColumnName="transponder_id",foreignAutoRefresh=true)
	private Transponder transponder;

	@ForeignCollectionField(eager=false,orderAscending=true,orderColumnName="ordem")
	private ForeignCollection<BouquetService> bouquets;

	@DatabaseField(canBeNull=false,foreign=true,foreignAutoRefresh=true)
	private Profile profile;

	public boolean isHD(){
		return type==25;
	}

	public Profile getProfile() {
		return profile;
	}
	public void setProfile(Profile profile) {
		this.profile = profile;
	}

    public Service() {
	}


    @Override
    public String toString() {
        return reference + ": " + name;
    }


    public Serializable getId() {
		return id;
	}


    public String getSid() {
		return sid;
	}
    public void setSid(String sid) {
		this.sid = sid;
	}

    public String getName() {
		return name;
	}
    public void setName(String name) {
		this.name = name;
	}
    public String getReference() {
		return reference;
	}
    public void setReference(String reference) {
		this.reference = reference;
	}

    public Transponder getTransponder() {
		return transponder;
	}
    public void setTransponder(Transponder transponder) {
		this.transponder = transponder;
	}
    public void setType(int type) {
		this.type = type;
	}
    public int getType() {
		return type;
	}
    public ForeignCollection<BouquetService> getBouquets() {
		return bouquets;
	}

	@Override
	public int compareTo(Service another) {
		return name.compareTo(another.getName());
	}

}
